package reflect;

import java.lang.reflect.Method;

public class EeflectDemo5 {
    public static void main(String[] args) throws Exception {
        Person p=new Person();
        p.say("你好");
        Class cls=Class.forName("reflect.Person");
        Object obj=cls.newInstance();
        Method method=cls.getMethod("say",String.class);
        method.invoke(obj,"大家好");

        Class cls2=Class.forName("reflect.Person");
        Object obj2=cls2.newInstance();
        Method method2=cls2.getMethod("say",String.class,int.class);
        method2.invoke(obj2,"才是真的好",5);

    }
}
